#ifndef TOKEN_H
#define TOKEN_H

#include <wx/arrstr.h>
#include <wx/string.h>

#include <set>
#include <map>

class Token;
class TokenTree;

typedef std::set< int,    std::less<int>    > TokenIdxSet;
typedef std::set< size_t, std::less<size_t> > TokenFileSet;

enum TokenScope {
  tsUndefined = 0,
  tsPrivate,
  tsProtected,
  tsPublic
};

enum TokenKind {


  tkNamespace        = 0x0001,


  tkClass            = 0x0002,


  tkEnum             = 0x0004,


  tkTypedef          = 0x0008,


  tkConstructor      = 0x0010,


  tkDestructor       = 0x0020,


  tkFunction         = 0x0040,


  tkVariable         = 0x0080,


  tkEnumerator       = 0x0100,


  tkMacroDef         = 0x0200,


  tkMacroUse         = 0x0400,
  tkAnyContainer     = tkClass    | tkNamespace   | tkTypedef,


  tkAnyFunction      = tkFunction | tkConstructor | tkDestructor,


  tkUndefined        = 0xFFFF
};

class Token {
    friend class TokenTree;
  public:


    Token( const wxString& name, unsigned int file, unsigned int line, size_t ticket );


    ~Token();


    bool AddChild( int childIdx );


    bool DeleteAllChildren();


    bool HasChildren() const { return !m_Children.empty(); }


    wxString GetNamespace() const;


    bool InheritsFrom( int idx ) const;


    wxString DisplayName() const;


    wxString GetTokenKindString() const;


    wxString GetTokenScopeString() const;


    wxString GetFilename() const;


    wxString GetImplFilename() const;


    wxString GetFormattedArgs() const;


    wxString GetStrippedArgs() const;


    size_t GetTicket() const { return m_Ticket; }


    bool MatchesFiles( const TokenFileSet& files );


    TokenTree* GetTree() const { return m_TokenTree; }


    bool IsValidAncestor( const wxString& ancestor );


    wxString                     m_FullType;


    wxString                     m_BaseType;


    wxString                     m_Name;


    wxString                     m_Args;


    wxString                     m_BaseArgs;


    wxString                     m_AncestorsString;


    unsigned int                 m_FileIdx;


    unsigned int                 m_Line;


    wxString                     m_Doc;


    unsigned int                 m_ImplFileIdx;


    unsigned int                 m_ImplLine;


    unsigned int                 m_ImplLineStart;


    unsigned int                 m_ImplLineEnd;


    wxString                     m_ImplDoc;


    TokenScope                   m_Scope;


    TokenKind                    m_TokenKind;


    bool                         m_IsOperator;


    bool                         m_IsLocal;


    bool                         m_IsTemp;


    bool                         m_IsConst;


    bool                         m_IsNoExcept;


    bool                         m_IsAnonymous;


    int                          m_Index;


    int                          m_ParentIndex;


    TokenIdxSet                  m_Children;


    TokenIdxSet                  m_Ancestors;


    TokenIdxSet                  m_DirectAncestors;


    TokenIdxSet                  m_Descendants;


    wxArrayString                m_Aliases;


    wxString                     m_TemplateArgument;


    wxArrayString                m_TemplateType;


    std::map<wxString, wxString> m_TemplateMap;


    wxString                     m_TemplateAlias;


    void*                        m_UserData;

  protected:


    TokenTree*                   m_TokenTree;


    size_t                       m_Ticket;
};

#endif
